package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.RegisterDto;
import edu.suda.xsap.dto.convert.RegisterConvert;
import edu.suda.xsap.entity.Register;
import edu.suda.xsap.mapper.RegisterMapper;
import edu.suda.xsap.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegisterServiceImpl implements RegisterService{
    @Autowired
    RegisterMapper registerMapper;

    @Autowired
    RegisterConvert registerConvert;
    @Override
    public void save(Register register) {
        registerMapper.save(register);
    }
    @Override
    public RegisterDto findByName(String name) {
        Register register = registerMapper.findByName(name);
        return registerConvert.toDto(register);
    }
    @Override
    public void update(Register register) {
        registerMapper.update(register);
    }
    @Override
    public List<RegisterDto> findAll() {
        List<Register> register=registerMapper.findAll();
        return registerConvert.toDtoList(register);
    }
}
